<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>VRD内容管理系统</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        body{
            background-color: #2e2e2e;
        }
        .navbar{
            background-color: black;
            margin-top: 10px;
            border: 0;
        }
        .navbar-brand>img{
            position: relative;
            bottom: 10px;
        }
        /*搜索框样式*/
        form>input{
            background-color: #383838;
            height: 30px;
            border: 0;
            padding: 10px 20px;
            border-radius: 30px;
            margin-top: 10px;
            color: #a8a8a8;
            outline: 0;/*去掉自带外边框*/
        }
        form>button{
            background-color: rgba(0,0,0,0);
            border: 0;
            color: #a8a8a8;
            position: relative;
            right: 40px;
        }
        /*瀑布流相关样式*/
        .grid-item{
            width: 200px;/*瀑布流中图片显示的宽度*/
            margin: 0 10px 10px 0;/*设置间距*/
        }
        /*右侧样式*/
        .list-group-item{
            background-color: black;
            color: #ffc600;
            border: 0;
        }
        .list-head{
            background-color: #ffc600;
            color: black;
        }
        .well{
            background-color: black;
            color: #ffc600;
            font-weight: bold;
            text-align: center;
            border: 0;
        }
        /*蓝色条相关样式*/
        .grid-item>div{
            width: 100%;
            background-color: #0aa1ed;
            color: #ffc600;
            text-align: center;
            position: absolute;
            bottom: 0;
            height: 40px;
            display: none;/*隐藏*/
        }
        .grid-item>div>p{
            margin:3px 0 0 0;/*去掉自带外边距*/
        }
        /*图片缩放动画*/
        img{
            transition-duration: 2s;
        }
        img:hover{
            transform: scale(1.2);/*缩放1.2倍*/
        }
        .grid-item{
            overflow: hidden;/*超出不显示“*/
        }
    </style>
</head>
<body>
<myheader :c_arr="c_arr" :search="search" :user="user" :kw="kw"></myheader>
<section class="container">

    <!--主体区域开始-->
    <div class="row">
        <div id="detail_div" style="color: #ffc600;text-align: center"  class="col-md-9">
            <!--详情开始-->
            <h2>{{product.title}}</h2>
            <hr>
            <div style="text-align: left">
                {{product.author}}发布于{{product.created}}
                <span class="pull-right"><!--显示到右侧-->
                    <span class="fa fa-eye">{{product.viewCount}}</span>
                    <span class="fa fa-thumbs-o-up">{{product.likeCount}}</span>
                </span>
            </div>
            <button class="btn btn-info" @click="like()">给作品点赞</button>
            <div style="margin: 30px 0;overflow: hidden">
                <!--center-block 让块级元素或行内块元素 居中-->
                <img :src="product.url" class="img-responsive center-block" alt="">
            </div>
            <p>{{product.intro}}</p>
            <!--详情结束-->
        </div>
        <div id="right_div" class="col-md-3">
            <rightdiv :like_arr="like_arr" :view_arr="view_arr"></rightdiv>
        </div>
    </div>
    <!--主体区域结束-->
</section>
<footer class="container">
    <div class="well">Copyright © 北京达内金桥科技有限公司版权所有 京ICP备12003709号-3</div>
</footer>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="js/header.js"></script>
<script src="js/right.js"></script>
<script src="http://cdn.staticfile.org/moment.js/2.24.0/moment.js"></script>
<script>
let vm =new Vue({
    el:"#detail_div",
    data:{
        product:{}
    },
    created:function () {
        //得到地址栏中的id
        let id=location.search.split("=")[1];
        axios.get("/product/detail?id="+id).then(function (response) {
            vm.product=response.data;
            vm.product.created=moment(vm.product.created).format("YYYY年MM月DD日 HH:mm:ss");
        })
    },
    methods:{
        like:function () {
            axios.get("/product/like?id="+vm.product.id).then(function (response) {
                if (response.data==1){
                    alert("点赞成功！");
                    // location.reload();
                    vm.product.likeCount++;
                }else {
                    alert("不能重复点赞！");
                }

            })
        }
    }
})


</script>

</body>
</html>